package com.spinus.spinusdemo.porttest;


import com.alibaba.fastjson.JSON;
import com.spinus.spinusdemo.base.Base;
import com.spinus.spinusdemo.utils.OkHttpUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;

/**
 * @author wuyongsheng
 * @description 解锁优惠券(unlock_coupon)(当优惠券状态为2时，把优惠券状态改为0)
 * @date 2019/4/19 21:26
 **/
@Slf4j
public class UnlockCouponMainServiceTest {
    public static void main(String[] args) {

        List<Map<String,String>> couponIds = new ArrayList<>();
        Map<String,String> map1 = new HashMap<>();
        map1.put("couponId","0bd1420e-270f-436a-a5c6-7bdf61dec621");
        couponIds.add(map1);
        Map<String,String> map2 = new HashMap<>();
        map2.put("couponId","0bd1420e-270f-436a-a5c6-7bdf61dec621");
        couponIds.add(map2);
        Map<String,String> map3 = new HashMap<>();
        map3.put("couponId","0bd1420e-270f-436a-a5c6-7bdf61dec621");
        couponIds.add(map3);

        Map<String,List<Map<String,String>>> data = new HashMap<>(1);

        data.put("couponIds",couponIds);
        Map<String, String> params =
            Base.getStringStringMap(Base.UNLOCK_COUPON);
        params.put("data", JSON.toJSONString(data));
        params.put("sign",Base.getComparedSign(params,Base.APPKEY));
        String post = OkHttpUtil.post(Base.TESTADDRESS, params);
        log.info(post);
        log.info("--------------------");
        log.info(params.get("data"));
    }
}
